import instance from "@/http/index.js"

// 获取部门消息 参数 id department
export const getDepartmentMsgAPI = (data) => {
  const { id, department } = data
  return instance({
    url: "/departmentMsg/getDepartmentMsg",
    method: "post",
    data: {
      department,
      id
    }
  })
}


// 获取部门消息列表 参数 department
export const getDepartmentMsgListAPI = (data) => {
  const { department } = data
  return instance({
    url: "/departmentMsg/getDepartmentMsgList",
    method: "post",
    data: {
      department
    }
  })
}

// 获取该用户的未读消息 read_list 和 阅读状态 read_status 参数 id
export const getReadListAPI = (data) => {
  const { id } = data
  return instance({
    url: "/departmentMsg/getReadList",
    method: "post",
    data: {
      id
    }
  })
}

// 当用户点击这条消息时, 把当前消息从 read_list 中删除 参数 id readId
export const readMessageAPI = (data) => {
  const { id, readId } = data
  return instance({
    url: "/departmentMsg/readMessage",
    method: "post",
    data: {
      id,
      readId
    }
  })
}

// 把新发布的消息 id 插入到当前所属部门的 read_list 中, 参数: readId, department
export const addDepartmentMsgAPI = (data) => {
  const { readId, department } = data
  return instance({
    url: "/departmentMsg/addDepartmentMsg",
    method: "post",
    data: {
      readId,
      department
    }
  })
}

// 把新发布的消息 id 从当前所属部门的 read_list 中删除, 参数: readId, department
export const deleteDepartmentMsgAPI = (data) => {
  const { readId, department } = data
  return instance({
    url: "/departmentMsg/deleteDepartmentMsg",
    method: "post",
    data: {
      readId,
      department
    }
  })
}

// 获取用户未读的消息内容
export const getUserMsgAPI = (data) => {
  const { id } = data
  return instance({
    url: "/departmentMsg/getUserMsg",
    method: "post",
    data: {
      id
    }
  })
}

